package de.fhkl.android.utils;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;

public class AndroidUtil {
	public static int dip2Px(Context context, int dipValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		Log.w("scale", "scale=" + scale);
		return (int) (dipValue * scale + 0.5f);
	}

	public static int px2dip(Context context, int pxValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (pxValue / scale + 0.5f);
	}

	public static int getDisplayWidth(Activity activity) {
		WindowManager manage = activity.getWindowManager();
		Display display = manage.getDefaultDisplay();
		return display.getWidth();
	}
}
